<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>29_案例练习-阅读协议</title>
    </head>
    <body>
        <button disabled>确定(5s)</button>


        <script>
            var btn = document.querySelector('button');

            var n = 5;

            var timer = setInterval(function(){
                n--;
                btn.innerHTML = '确定(' + n + 's)';

                if(n == 0){
                    clearInterval(timer);
                    btn.innerHTML = '确定';
                    btn.disabled = false;
                }

            },1000);
        </script>
    </body>
</html>